// Source: http://www.threelas.com
// Modified by Taufik Nurrohman (http://hompimpaalaihumgambreng.blogspot.com)

function showrecentposts(a) {
	var b = a.feed.openSearch$totalResults.$t;
	if (b < numberpost) {
		numberpost = b - 1
	}
	for (var c = 0; c <= numberpost; c++) {
		post[c] = a.feed.entry[c].title.$t;
		label[c] = a.feed.entry[c].category[0].term;
		timepub[c] = a.feed.entry[c].published.$t.substring(0, 10)
	}
	var d = new Array;
	for (var c = 0; c <= numberpost; c++) {
		for (var e = 0; e <= a.feed.entry[c].link.length - 1; e++) {
			if (a.feed.entry[c].link[e].rel == "alternate") {
				d[c] = a.feed.entry[c].link[e].href;
				break
			}
		}
	}
	document.write('<select id="tocSort" onchange="displaymessage(this.options[this.selectedIndex].value);"><option value="0">' + theOption + '</option><option value="0">' + theSortPost + '</option><option value="1">' + theSortLabel + '</option></select>');
	document.write('<table border="1" id="tocTable"><thead><tr><th id="th1">' + theJudul + '</th><th id="th2">' + theLabel + '<th id="th3">' + theDate + '</th>');
	document.write('</tr></thead>');
	document.write('<tbody id="toc">');
	for (var c = 0; c <= numberpost; c++) {
		if (a.feed.entry[c].category.length >= 1) {
			for (var e = 0; e <= a.feed.entry[c].category.length - 1; e++) {
				document.write('<tr>');
				document.write('<td class="toc-header-col1">' + '<a href="' + d[c] + '" target="_blank">' + post[c] + "</a>" + '</td>');
				document.write('<td class="toc-header-col2">' + '<a href="' + yoursite + "/search/label/" + a.feed.entry[c].category[e].term + '" target="_blank">' + a.feed.entry[c].category[e].term + "</a>" + '</td>');
				document.write('<td class="toc-header-col3">' + timepub[c] + '</td>');
				document.write('</tr>')
			}
		} else {
			document.write('<tr>');
			document.write('<td class="toc-header-col1">' + '<a href="' + d + '" target="_blank">' + post[c] + "</a>" + '</td>');
			document.write('<td class="toc-header-col2">' + blankLabel + '</td>');
			document.write('<td class="toc-header-col3">' + timepub[c] + '</td>');
			document.write('</tr>')
		}
	}
	document.write('</tbody>');
	document.write('</table>')
}
function getTextValue(a) {
	var b;
	var c;
	c = "";
	for (b = 0; b < a.childNodes.length; b++) if (a.childNodes[b].nodeType == document.TEXT_NODE) c += a.childNodes[b].nodeValue;
	else if (a.childNodes[b].nodeType == document.ELEMENT_NODE && a.childNodes[b].tagName == "BR") c += " ";
	else c += getTextValue(a.childNodes[b]);
	return normalizeString(c)
}
function normalizeString(a) {
	a = a.replace(whtSpMult, " ");
	a = a.replace(whtSpEnds, "");
	return a
}
function compareValues(a, b) {
	var c, d;
	c = parseFloat(a);
	d = parseFloat(b);
	if (!isNaN(c) && !isNaN(d)) {
		a = c;
		b = d
	}
	if (a == b) return 0;
	if (a > b) return 1;
	return -1
}
function displaymessage(a) {
	var b = document.getElementById("toc");
	if (b.reverseSort == null) b.reverseSort = new Array;
	if (a == b.lastColumn) b.reverseSort[a] = !b.reverseSort[a];
	b.lastColumn = a;
	var c = b.style.display;
	b.style.display = "none";
	var d;
	var e, f;
	var g, h;
	var i;
	var j;
	for (e = 0; e < b.rows.length - 1; e++) {
		h = e;
		g = getTextValue(b.rows[e].cells[a]);
		for (f = e + 1; f < b.rows.length; f++) {
			i = getTextValue(b.rows[f].cells[a]);
			j = compareValues(g, i);
			if (b.reverseSort[a]) j = -j;
			if (j > 0) {
				h = f;
				g = i
			}
		}
		if (h > e) {
			d = b.removeChild(b.rows[h]);
			b.insertBefore(d, b.rows[e])
		}
	}
	b.style.display = c;
	return false
}
var post = new Array;
var label = new Array;
var timepub = new Array;
if (document.ELEMENT_NODE == null) {
	document.ELEMENT_NODE = 1;
	document.TEXT_NODE = 3
}
var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
var whtSpMult = new RegExp("\\s\\s+", "g");